package com.springboot.cloud.demos.feign.events;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class BusSender {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * @param exchange 交换机
     * @param routingKey 路由key
     * @param message 消息体
     * */
    public void send(String exchange, String routingKey,String message) {
        log.info("exchange:{}=>routingKey:{}=>message:{}",exchange, routingKey, message);
        rabbitTemplate.convertAndSend(exchange ,routingKey, message);
    }
}
